#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>

#include "point.h"
#include "segment.h"

class quick_hull_distance_comparator: public distance_comparator
{
    public:
        quick_hull_distance_comparator(const segment &s): distance_comparator(s)
        {
        }

        bool operator()(const point &a, const point &b) const
        {
            int d = s.further(a, b);

            if (d == 0)
                d = segment(s.a, a).left_turn(b);

            return d < 0;
        }
};

template <class ForwardIterator>
void quick_hull(const segment &s, ForwardIterator begin, ForwardIterator end, std::vector<point> &hull)
{
    if (begin == end)
        return;

    point p = *std::max_element(begin, end, quick_hull_distance_comparator(s));

    segment s1(s.a, p);
    ForwardIterator it1 = std::partition(begin, end, left_turn_predicate(s1));
    quick_hull(s1, begin, it1, hull);

    hull.push_back(p);

    segment s2(p, s.b);
    ForwardIterator it2 = std::partition(it1, end, left_turn_predicate(s2));
    quick_hull(s2, it1, it2, hull);
}

template <class ForwardIterator>
void quick_hull(ForwardIterator begin, ForwardIterator end, std::vector<point> &hull)
{
    if (begin == end)
        return;

    std::pair<ForwardIterator, ForwardIterator> minmax = std::minmax_element(begin, end, point_comparator());
    point min = *minmax.first;
    point max = *minmax.second;

    if (max != min)
        hull.push_back(min);

    segment s1(min, max);
    ForwardIterator it1 = std::partition(begin, end, left_turn_predicate(s1));
    quick_hull(s1, begin, it1, hull);

    hull.push_back(max);

    segment s2(max, min);
    ForwardIterator it2 = std::partition(it1, end, left_turn_predicate(s2));
    quick_hull(s2, it1, it2, hull);
}

int main()
{
    int n;
    std::cin >> n;

    std::vector<point> set;

    for (int i = 0; i < n; i++)
    {
        point p;
        std::cin >> p;

        set.push_back(p);
    }

    std::vector<point> hull;
    quick_hull(set.begin(), set.end(), hull);

    std::cout << hull.size() << "\n";
    std::cout << std::fixed << std::setprecision(50);
    for (std::vector<point>::const_iterator it = hull.begin(); it != hull.end(); it++)
    {
        std::cout << *it << "\n";
    }

    return 0;
}
